/*
 * Created on May 28, 2004
 *
 */
package littlecyberwar.tool;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.util.*;

import littlecyberwar.ui.*;


/**
 * @author Milton  Soong
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public abstract class MouseStraightHandler extends MultiSelectMouseHandler {
//	   a common superclass for different kind of mouse action to game command
//	   i.e. move straight (forward, backward, sidestep, freeform)


	  public MouseStraightHandler() {
		super();
	  }

	  public void startAction( MouseEvent e ) {
		super.startAction(e);
		startDragP = ScalingDelegate.getMouseEventLocation(e.getPoint());
		if ( selectedElements.size() == 0 ){
			Exception ex = new Exception();
			ex.printStackTrace();
		}
		// transform p to match selected rectangle user space
		SelectedElementContainer selElCont = (SelectedElementContainer)selectedElements.get(0);
		Element el =  selElCont.element;
		selectedTrans = el.getTransform();
		try {
		  selectedTrans.inverseTransform(startDragP, startDragP);
		} catch ( Exception ex ) {
		  ex.printStackTrace();
		}
		DirtyAreaManager.checkAndRepaint(comp);
	  }

}